#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;

//reference: https://blog.csdn.net/Van0512/article/details/53125103
int main()
{
    int N;
    unordered_map<string, int> dict;
    char s[12];
    cin >> N;
    for (int i = 0; i < 2 * N; i++)
    {
        scanf("%s", s);
        dict[s]++;
    }

    auto it = dict.cbegin();
    string minStr = it->first;
    int num = 1;
    int callCnt = it->second;
    for (++it; it != dict.cend(); ++it)
    {
        if(it->second > callCnt)
        {
            callCnt = it->second;
            minStr = it->first;
            num = 1;
        }
        else if (it->second == callCnt)
        {
            num++;
            if (it->first < minStr)
                minStr = it->first;
        }
    }
    cout << minStr << " " << callCnt;
    if (num > 1)
        cout << " " << num;
}